package com.googlecode.afx.view.behavior.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javafx.scene.Node;

import com.googlecode.afx.view.NodeHandler;
import com.googlecode.afx.view.NodeWrapper;

public class ViewHandlers {

	private static final Log LOG = LogFactory.getLog(ViewHandlers.class);

	/**
	 * <tt>NodeHandler</tt> implementation that enables a given node.
	 * 
	 * @author Martin
	 *
	 */
	public static final class EnableHandler implements NodeHandler {
		@Override
		public void process(Node node) {
			LOG.debug("Enabling node with id='" + node.getId() + "'");
			node.setDisable(false);
		}
	}

	/**
	 * <tt>NodeHandler</tt> implementation that disables a given node.
	 * 
	 * @author Martin
	 *
	 */
	public static final class DisableHandler implements NodeHandler {
		@Override
		public void process(Node node) {
			LOG.debug("Disabling node with id='" + node.getId() + "'");
			node.setDisable(true);
		}
	}

	/**
	 * <tt>NodeHandler</tt> implementation that hides a given node.
	 * 
	 * @author Martin
	 *
	 */
	public static final class HideHandler implements NodeHandler {
		@Override
		public void process(Node node) {
			LOG.debug("Hiding node with id='" + node.getId() + "'");
			node.setVisible(false);
		}
	}

	/**
	 * <tt>NodeHandler</tt> implementation that shows a given node.
	 * 
	 * @author Martin
	 *
	 */
	public static final class ShowHandler implements NodeHandler {
		@Override
		public void process(Node node) {
			LOG.debug("Showing node with id='" + node.getId() + "'");
			node.setVisible(true);
		}
	}

	/**
	 * <tt>NodeHandler</tt> implementation that resets the value of a given
	 * node.
	 * 
	 * @author Martin
	 *
	 */
	public static final class ResetHandler implements NodeHandler {
		@Override
		public void process(Node node) {
			if (NodeWrapper.supportsPrimaryValue(node.getClass())) {
				LOG.debug("Resetting node with id='" + node.getId() + "'");
				NodeWrapper wrapper = new NodeWrapper(node);
				
			}
		}
	}

}